package cn.zyjblogs.nio;

import java.nio.IntBuffer;

public class BasicBuffer {
    public static void main(String[] args) {
        //创建一个buffer
        IntBuffer intBuffer = IntBuffer.allocate(5);
        //向buffer中存入数据
        for (int i=0;i <intBuffer.capacity();i++){
            intBuffer.put(i<<1);
        }

        //如何从buffer读取数据
        //将buffer转换，读写切换
        intBuffer.flip();

        while (intBuffer.hasRemaining()){
            System.out.println(intBuffer.get());
        }

    }
}
